/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.homullus.SkeletonExporter;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.homullus.Bone;
import org.homullus.Pose;
import org.homullus.PoseDirection;
import org.homullus.Skeleton;

/**
 *
 * @author Gary
 */
public class COHExporter implements ISkeletonExporter
{
    public void Export(Pose pose, String filename)
    {
        try
        {
            FileOutputStream out = new FileOutputStream(filename);
            writebone(pose.getRootPose(), out);


        }
        catch (FileNotFoundException ex)
        {
            System.out.println("Error file not found!!!!!!!!!");
        }
        catch (IOException ex)
        {
            System.out.println("IOException!!!!!!!!!");
        }
    }

    private void writebone(PoseDirection p, FileOutputStream out) throws IOException
    {
        out.write((Float.toString(p.getPitch()) + " " + Float.toString(p.getYaw()) + " " + Float.toString(p.getRole()) + " ").getBytes());
        if (p.getChildPose() != null)
        {
            for (int sb = 0; sb < p.getChildPose().size(); sb++)
            {
                writebone(p.getChildPose().get(sb), out);
            }
        }
    }

    public String Description()
    {
        return "COH File";
    }

    public String Extension()
    {
        return "txt";
    }




}
